<?php
namespace app\admin\model;
use think\Db;
use think\Model;
use think\Session;

class Login extends Model{

    public function login($username, $password){
        $admin = Db::name('admin') -> where('username', $username)-> find();

        if($admin){
            if($admin['password'] == md5($password)){
                Session::set('id', $admin['id']);
                Session::set('username', $admin['username']);
                return 1;
            }else{
                return 2;
            }
        }else{
            return 3;
        }
    }
}